package com.lanou.dllo.shise.com.lanou.dllo.fragment;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lanou.dllo.shise.R;


public class MyFragmentFactory extends Fragment {
    private static final String ARGS_POSITION="position";
    private static SparseArray<Fragment> fragmentSparseArray = new SparseArray<>();
    public static Fragment newInstance(int position){
       Fragment f = fragmentSparseArray.get(position);
        if ((f == null )) {
            switch (position){
                case (0):
                    f = new Close_attentionFragment();
                    Bundle bundle_jokes = new Bundle();
                    bundle_jokes.putInt("position", position);
                    f.setArguments(bundle_jokes);
                    break;
                case (1):
                    f = new Same_cityFragment();
//                    Bundle bundle_images = new Bundle();
//                    bundle_images.putInt("position", position);
//                    f.setArguments(bundle_images);
                    break;
                default:
                    f = new Carefully_choseFragment();
//                    Bundle bundle_musics = new Bundle();
//                    bundle_musics.putInt("position", position);
//                    f.setArguments(bundle_musics);
                    break;
            }
            fragmentSparseArray.put(position,f);

        }
        return f;
    }

}
